class_name WeaponData
extends EntityData

#region 武器属性
@export_group("武器属性")
@export var weapon_id:String
@export var weapon_name:String
@export var weapon_desc:String
@export var weapon_sprite:Texture2D
#endregion
#region 特殊属性
@export_group("特殊属性")
#region 容量 Capacity
@export_subgroup("容量 Capacity")
# -1 表示无限容量
@export var clip_count:int = 0:
	get:return clip_count
	set(value):
		clip_count = value
		data_changed.emit("Capacity")
# -1 表示无限容量
@export var total_count:int = 0:
	get:return total_count
	set(value):
		total_count = value
		data_changed.emit("Capacity")
@export var reload_count:int = -1:
	get:return reload_count
	set(value):
		reload_count = value
		data_changed.emit("Capacity")
@export var reload_time:float = 0:
	get:return reload_time
	set(value):
		reload_time = value
		data_changed.emit("Capacity")
#endregion
#region 数量 Amount
@export_subgroup("数量 Amount")
@export_range(1,100) var count_per_round:int = 1:
	get:return count_per_round
	set(value):
		count_per_round = value
		data_changed.emit("Amount")
@export var is_random_count_per_round:bool = false:
	get:return is_random_count_per_round
	set(value):
		is_random_count_per_round = value
		data_changed.emit("Amount")
@export var random_count_per_round_range:Vector2i = Vector2i.ONE:
	get:return random_count_per_round_range
	set(value):
		random_count_per_round_range = value
		data_changed.emit("Amount")
@export var interval_per_one:float = 0:
	get:return interval_per_one
	set(value):
		interval_per_one = value
		data_changed.emit("Amount")
@export_range(1,100) var round_amount:int = 1:
	get:return round_amount
	set(value):
		round_amount = value
		data_changed.emit("Amount")
@export var is_random_round_amount:bool = false:
	get:return is_random_round_amount
	set(value):
		is_random_round_amount = value
		data_changed.emit("Amount")
@export var random_round_amount_range:Vector2i = Vector2i.ONE:
	get:return random_round_amount_range
	set(value):
		random_round_amount_range = value
		data_changed.emit("Amount")
@export var interval_per_round:float = 0:
	get:return interval_per_round
	set(value):
		interval_per_round = value
		data_changed.emit("Amount")
func get_round_amount() -> int:
	if is_random_round_amount:
		return randi_range(random_round_amount_range.x,random_round_amount_range.y)
	else:
		return round_amount
func get_count_per_round() -> int:
	if is_random_count_per_round:
		return randi_range(random_count_per_round_range.x,random_round_amount_range.y)
	else:
		return count_per_round
#endregion
#region 散射 Scattering
@export_subgroup("散射 Scattering")
@export var scattering_angle:float = 0: # 全角
	get:return scattering_angle
	set(value):
		scattering_angle = value
		data_changed.emit("Scattering")
@export var is_random_scattering_angle:bool = false:
	get:return is_random_scattering_angle
	set(value):
		is_random_scattering_angle = value
		data_changed.emit("Scattering")
@export var scattering_angle_random_range:Vector2 = Vector2.ZERO:
	get:return scattering_angle_random_range
	set(value):
		scattering_angle_random_range = value
		data_changed.emit("Scattering")
func get_scattering_angle() -> float:
	if is_random_scattering_angle:
		return randf_range(scattering_angle_random_range.x,scattering_angle_random_range.y)
	else:
		return scattering_angle 
#endregion
#region 时间 Time
@export_subgroup("时间 Time")
@export var attack_cooling_time:float = 0:
	get:return attack_cooling_time
	set(value):
		attack_cooling_time = value
		data_changed.emit("Time")
@export var skill_cooling_time:float = 0:
	get:return skill_cooling_time
	set(value):
		skill_cooling_time = value
		data_changed.emit("Time")
#endregion
#region 预制体 Prefab
@export_subgroup("预制体 Prefab")
@export var prefabs:Array[PackedScene] = []:
	get:return prefabs
	set(value):
		prefabs = value
		data_changed.emit("Prefab")
#endregion
@export_group("")
#endregion

#新增组别实例
#@export_subgroup("分组名 tag")
#@export var xxx:int = 0:
	#get:return xxx
	#set(value):
		#xxx = value
		#data_changed.emit("Tag")
